<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script>
      /**
       * 只会执行一次
       */
      var num = 1;
      var timer = setTimeout(function () {
        console.log(num++);
      }, 2000);
      // 关闭延时调用
      clearTimeout(timer);
    </script>
  </head>
  <body></body>
</html>
